package com.liuyu.common.framework.rocketmq.service.facade;

import com.liuyu.common.framework.rocketmq.vo.MqMessage;
import org.apache.rocketmq.client.producer.TransactionSendResult;

import java.util.Map;

/**
 * @ClassName MessageProducerService

 * @Author: liuyu
 * @Date: Created in 2021/7/29 14:58
 * @Version: 1
 * @Modified By:
 */
public interface MessageProducerService {

    /**
     *
     * 发送普通的消息
     * @author liuyu
     * @date 2022/4/24 9:42
     * @param topic
     * @param message
     * @return void
     * @throws Exception
     */
    <T> void sendMessage(String topic, MqMessage<T> message) throws Exception;


    /**
     * 发送普通的消息
     * 通过key 的hash选择一个队列，保证一组数据的局部顺序性。
     * @author liuyu
     * @date 2021/7/29 15:04
     * @param topic
     * @param message
     * @return void
     * @throws Exception
     */
    <T> void sendOrderMessage(String topic, MqMessage<T> message) throws Exception;


    /**
     * 发送事务消息
     * @author liuyu
     * @date 2021/12/23 11:05
     * @param topicName
     * @param message
     * @param object
     * @param header
     * @return org.apache.rocketmq.client.producer.TransactionSendResult
     */
    <T> TransactionSendResult sendMessageInTransaction(String topicName, MqMessage<T> message, Object object, Map<String,Object> header);

}
